package ubi.quando.App;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.osmdroid.util.GeoPoint;
import java.util.Date;

public class PickUpParticipant implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String SerializeName = "PickUpParticipant";;

	private GeoPoint mLocation;
	private String mLocName;
	private Date mDate;
//	private Contact mContact;
	private String mContact;
	private String mName;
	private String mEmail;

	public PickUpParticipant()
	{
		mContact = null;
		mDate = null;
		mLocation = null;
	}
	
	public PickUpParticipant(GeoPoint location, Date date, /*Contact contact*/String contact) {
		mContact = contact;
		mDate = date;
		mLocation = location;
	}

	public void setContact(/*Contact*/String contact) {
		this.mContact = contact;
	}

	public void setDate(Date date) {
		this.mDate = date;
	}

	public void setLocation(GeoPoint location) {
		this.mLocation = location;
	}

	public /*Contact*/String getContact() {
		return mContact;
	}

	public Date getDate() {
		return mDate;
	}

	public GeoPoint getLocation() {
		return mLocation;
	}
	
	public void setLocName(String locName) {
		mLocName = locName;
	}
	
	public String getLocName() {
		return mLocName;
	}

	protected void writeObject(ObjectOutputStream out) throws IOException {
		out.writeObject(mDate);
		out.writeObject(mLocation);
		out.writeObject(mLocName);
		out.writeObject(mContact);
		out.writeObject(mName);
		out.writeObject(mEmail);
	}

	protected void readObject(ObjectInputStream in) throws IOException,
			ClassNotFoundException {
		Object temp = in.readObject();
		if (temp != null) {
			mDate = (Date) temp;
		}
		temp = in.readObject();
		if (temp != null) {
			mLocation = (GeoPoint) temp;
		}
		temp = in.readObject();
		if (temp != null) {
			mLocName = (String) temp;
		}
		temp = in.readObject();
		if (temp != null) {
			mContact = /*(Contact)*/(String) temp;
		}
		temp = in.readObject();
		if (temp != null) {
			mName = (String) temp;
		}
		temp = in.readObject();
		if (temp != null) {
			mEmail = (String) temp;
		}
	}
	
	@Override
	public boolean equals(Object o) {
		PickUpParticipant other = (PickUpParticipant) o;
		/*Contact*/String otherContact = other.getContact();
		/*Contact*/String thisContact = getContact();
		if(otherContact != null && thisContact != null)
		{
			return thisContact.equals(otherContact);
		}
		return false;
	}

	public void setEmail(String email) {
		this.mEmail = email;
	}

	public String getEmail() {
		return mEmail;
	}

	public void setName(String name) {
		this.mName = name;
	}

	public String getName() {
		return mName;
	}
}
